package com.winter.service;

import com.winter.mapper.IAttaMapper;
import com.winter.model.IAtta;
import com.winter.util.Result;
import com.winter.util.ResultCode;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;

@Service
public class UploadingService {

    @Autowired
    private IAttaMapper iAttaMapper;


    /**
     * 上传配件
     */
    public Result accessory(IAtta iAtta) {
        if (iAtta == null) {
            return Result.failure(ResultCode.PARAM_IS_BLANK);
        }
        if (iAtta.getCreateUser() == null) {
            return Result.failure(ResultCode.USER_NOT_LOGGED_IN);
        }
        iAtta.setUpdatetime(new Date());
        iAtta.setCreatetime(new Date());
        iAtta.setUpdateUser(iAtta.getCreateUser());
        int i = iAttaMapper.insertSelective(iAtta);
        if (i > 0) {
            return Result.success();
        }
        return Result.failure(ResultCode.FAILURE);
    }
}
